---------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/clotairemit.edu/Dropbox (MIT)/J-PAL Raskin Transition/10_Analysis&Results/Agent Experiment Analysis/03_
> Logs/20240426_agents.log
  log type:  text
 opened on:  26 Apr 2024, 00:11:18

. 
. 
. clear

. set more off

. set seed 11022022

. 
. global finance_data "$cleaned/finance"

. 
. 
. *** IE Treatment Effect on Agents
. * winsorize continuous variables
. u "$finance_data/mar19_village_IE_treats_lasso.dta", clear

. 
. gen agent_mar18 = agentsw_mar18 > 0

. 
. gen agent_total = agents_total > 0

. 
. foreach var in agents ratio agent {
  2.   gen `var'W_total = `var'_total
  3.   _pctile `var'_total, p(0.5 99.5)
  4.   replace `var'W_total = `r(r1)' if `var'_total < `r(r1)'
  5.   replace `var'W_total = `r(r2)' if `var'_total > `r(r2)' & `var'_total != .
  6.   gen `var'W_mar18 = `var'_mar18
  7. }
(0 real changes made)
(100 real changes made)
(0 real changes made)
(98 real changes made)
(0 real changes made)
(0 real changes made)

. // summ agents_total agentsW_total
. // summ ratio_total ratioW_total
. 
. * sample cuts
. gen agents2 = agents_mar18 < 2

. gen agents0 = agents_mar18 == 0

. gen benef = min2_mar18 == 0 & beneficiaries < 500

. gen all = 1

. rename Kabupaten namakabupaten

. est clear

. eststo clear

. 
. 
. * regression loop agents agentsW ratio ratioW both ratio250 min2
. foreach var in agentsW agent {
  2. 
.   foreach sample in  agents0 all {
  3.     ** regression with Lasso
.     qui eststo `var'`sample'IE: pdslasso `var'_total treated (i.finalstratum log_beneficiaries `var'_mar18* *podes) ///
>       if `sample' == 1, aset(i.finalstratum `var'_mar18*) cluster(idkab)
  4.       qui summ `var'_total if e(sample) == 1 & treated == 0
  5.       estadd scalar control_mean = r(mean)
  6.       estadd scalar control_sd = r(sd)
  7.       estadd scalar obs = e(N)
  8.       estadd scalar select_num = e(xselected_ct) - e(xaset_ct)
  9.       estadd local stratum = "Yes"
 10.       estadd local lasso = "Yes"
 11. 
.     ** RI p-val
.     randinference treated using "$importable/resample1000.dta", ///
>       reg(reg `var'_total treated `e(xselected)' if `sample' == 1, vce(cluster idkab)) ///
>       reps($RI) mergevar(namakabupaten) mergetype(m:1)
 12.     matrix define pvalues = (`r(RIpval)')
 13.     matrix colnames pvalues = treated
 14.     est restore `var'`sample'IE
 15.     estadd matrix pvalues
 16. 
.   }
 17. }

added scalar:
       e(control_mean) =  .57890751

added scalar:
         e(control_sd) =  1.2065976

added scalar:
                e(obs) =  14625

added scalar:
         e(select_num) =  9

added macro:
            e(stratum) : "Yes"

added macro:
              e(lasso) : "Yes"
Original regression:
note: agentsW_mar18 omitted because of collinearity.

Linear regression                               Number of obs     =     14,625
                                                F(24, 104)        =      21.29
                                                Prob > F          =     0.0000
                                                R-squared         =     0.2007
                                                Root MSE          =     1.1907

                                          (Std. err. adjusted for 105 clusters in idkab)
----------------------------------------------------------------------------------------
                       |               Robust
         agentsW_total | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------------+----------------------------------------------------------------
               treated |   .3929962   .1067865     3.68   0.000     .1812346    .6047578
                       |
          finalstratum |
                    2  |   .0434176   .1485515     0.29   0.771    -.2511656    .3380009
                    3  |  -.3965338   .1329279    -2.98   0.004    -.6601348   -.1329328
                    4  |  -.1252499   .1657572    -0.76   0.452    -.4539526    .2034529
                    5  |   .3013666   .2987384     1.01   0.315    -.2910428     .893776
                    6  |  -.0167893   .1018161    -0.16   0.869    -.2186945    .1851158
                    7  |  -.2327737    .214215    -1.09   0.280    -.6575701    .1920226
                    8  |   .3032803   .1978903     1.53   0.128    -.0891436    .6957041
                    9  |  -.0408087   .1138659    -0.36   0.721    -.2666092    .1849917
                   10  |   .3060143   .1824053     1.68   0.096    -.0557024     .667731
                   11  |   .2739693    .191327     1.43   0.155    -.1054394    .6533779
                   12  |   .4245318   .2162368     1.96   0.052    -.0042739    .8533376
                   13  |  -.1082833   .0852094    -1.27   0.207    -.2772567    .0606902
                   14  |    .187252   .2835748     0.66   0.511    -.3750875    .7495916
                 1000  |   .3062469    .150584     2.03   0.045     .0076333    .6048606
                       |
     log_beneficiaries |   .2711738    .041309     6.56   0.000     .1892566    .3530911
         agentsW_mar18 |          0  (omitted)
    himbara_bank_podes |   .6251602   .1160969     5.38   0.000     .3949356    .8553847
             atm_podes |   .4628982   .0768986     6.02   0.000     .3104054    .6153911
           agent_podes |   .3446718   .0852161     4.04   0.000     .1756851    .5136586
weak_cell_signal_podes |  -.1914971   .0310956    -6.16   0.000    -.2531609   -.1298333
  no_cell_signal_podes |  -.2984701   .0599222    -4.98   0.000     -.417298   -.1796422
internet_cell_4G_podes |   .1114958   .0313037     3.56   0.001     .0494194    .1735722
 desa_head_edu18_podes |   .0370667    .009068     4.09   0.000     .0190846    .0550488
   no_bankaccess_podes |  -.1048104   .0808401    -1.30   0.198    -.2651193    .0554985
                 _cons |  -.8631226   .1754905    -4.92   0.000    -1.211127   -.5151183
----------------------------------------------------------------------------------------
Beginning 1000 regressions...
Completed regression 10
Completed regression 25
Completed regression 50
Completed regression 100
Completed regression 200
Completed regression 300
Completed regression 400
Completed regression 500
Completed regression 600
Completed regression 700
Completed regression 800
Completed regression 900
Completed regression 1000
RI p-val = 0
(results agentsWagents0IE are active now)

added matrix:
            e(pvalues) :  1 x 1

added scalar:
       e(control_mean) =  1.3074074

added scalar:
         e(control_sd) =  2.5890083

added scalar:
                e(obs) =  20743

added scalar:
         e(select_num) =  12

added macro:
            e(stratum) : "Yes"

added macro:
              e(lasso) : "Yes"
Original regression:

Linear regression                               Number of obs     =     20,743
                                                F(28, 104)        =      44.13
                                                Prob > F          =     0.0000
                                                R-squared         =     0.5597
                                                Root MSE          =     1.9206

                                           (Std. err. adjusted for 105 clusters in idkab)
-----------------------------------------------------------------------------------------
                        |               Robust
          agentsW_total | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
------------------------+----------------------------------------------------------------
                treated |   .3819406   .1326531     2.88   0.005     .1188845    .6449966
                        |
           finalstratum |
                     2  |   .1366058    .371867     0.37   0.714    -.6008205    .8740321
                     3  |  -.4717228    .137789    -3.42   0.001    -.7449636    -.198482
                     4  |  -.2354626   .1777199    -1.32   0.188    -.5878879    .1169626
                     5  |   .1102503   .3471357     0.32   0.751    -.5781328    .7986334
                     6  |  -.1819236   .1485823    -1.22   0.224    -.4765679    .1127206
                     7  |  -.6641403   .2695417    -2.46   0.015    -1.198652    -.129629
                     8  |   .5631717   .1949138     2.89   0.005     .1766503    .9496931
                     9  |  -.1883774   .1414267    -1.33   0.186    -.4688318    .0920771
                    10  |   .4826317   .2329655     2.07   0.041     .0206524     .944611
                    11  |   .0219627   .3139084     0.07   0.944    -.6005295    .6444549
                    12  |   .5082704    .356837     1.42   0.157    -.1993509    1.215892
                    13  |  -.0778391   .1045836    -0.74   0.458    -.2852324    .1295542
                    14  |   .5808429   .3417049     1.70   0.092    -.0967706    1.258456
                  1000  |   .4875111   .2094517     2.33   0.022     .0721605    .9028617
                        |
      log_beneficiaries |   .3525213   .0421099     8.37   0.000     .2690157    .4360269
          agentsW_mar18 |    .945714   .0675779    13.99   0.000     .8117045    1.079724
     himbara_bank_podes |    1.05355   .1490827     7.07   0.000     .7579134    1.349187
dist_himbara_bank_podes |  -.0037788   .0014269    -2.65   0.009    -.0066083   -.0009493
     private_bank_podes |   .8788102   .3060327     2.87   0.005      .271936    1.485685
              atm_podes |   .6832995   .0977096     6.99   0.000     .4895377    .8770613
            agent_podes |   .6116843   .1437452     4.26   0.000     .3266321    .8967365
         non_agri_podes |   .2817824   .0907063     3.11   0.002     .1019083    .4616565
 weak_cell_signal_podes |  -.2185039   .0357009    -6.12   0.000    -.2893002   -.1477077
   no_cell_signal_podes |  -.1547819   .0949393    -1.63   0.106    -.3430501    .0334863
 internet_cell_4G_podes |   .0906277   .0336456     2.69   0.008     .0239073    .1573482
  desa_head_edu18_podes |   .0474801   .0140534     3.38   0.001     .0196116    .0753485
    no_bankaccess_podes |   .0856872   .1306657     0.66   0.513    -.1734278    .3448022
                  _cons |   -1.39905   .2111906    -6.62   0.000    -1.817849   -.9802511
-----------------------------------------------------------------------------------------
Beginning 1000 regressions...
Completed regression 10
Completed regression 25
Completed regression 50
Completed regression 100
Completed regression 200
Completed regression 300
Completed regression 400
Completed regression 500
Completed regression 600
Completed regression 700
Completed regression 800
Completed regression 900
Completed regression 1000
RI p-val = .004
(results agentsWallIE are active now)

added matrix:
            e(pvalues) :  1 x 1

added scalar:
       e(control_mean) =  .33683613

added scalar:
         e(control_sd) =  .47265072

added scalar:
                e(obs) =  14625

added scalar:
         e(select_num) =  8

added macro:
            e(stratum) : "Yes"

added macro:
              e(lasso) : "Yes"
Original regression:
note: agent_mar18 omitted because of collinearity.

Linear regression                               Number of obs     =     14,625
                                                F(23, 104)        =      54.10
                                                Prob > F          =     0.0000
                                                R-squared         =     0.2141
                                                Root MSE          =     .43901

                                          (Std. err. adjusted for 105 clusters in idkab)
----------------------------------------------------------------------------------------
                       |               Robust
           agent_total | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-----------------------+----------------------------------------------------------------
               treated |   .2291604   .0483368     4.74   0.000     .1333067    .3250142
                       |
          finalstratum |
                    2  |   .1004501    .039358     2.55   0.012     .0224016    .1784985
                    3  |  -.0450535   .0545089    -0.83   0.410    -.1531468    .0630397
                    4  |   .0864804   .0832085     1.04   0.301    -.0785252    .2514859
                    5  |   .2188385    .130896     1.67   0.098    -.0407331    .4784102
                    6  |   .0797562   .0765763     1.04   0.300    -.0720975    .2316098
                    7  |  -.0243978   .0689554    -0.35   0.724    -.1611391    .1123434
                    8  |   .2068281   .0639211     3.24   0.002     .0800701     .333586
                    9  |   .0191198   .0532405     0.36   0.720    -.0864581    .1246977
                   10  |   .0869131   .0807467     1.08   0.284    -.0732106    .2470368
                   11  |   .1677679    .065922     2.54   0.012     .0370422    .2984937
                   12  |   .2052377   .0695448     2.95   0.004     .0673277    .3431477
                   13  |  -.0078752   .0456424    -0.17   0.863    -.0983859    .0826354
                   14  |    .094552    .116567     0.81   0.419    -.1366048    .3257088
                 1000  |   .1385057   .0709754     1.95   0.054    -.0022412    .2792526
                       |
     log_beneficiaries |   .0981359   .0127554     7.69   0.000     .0728415    .1234304
           agent_mar18 |          0  (omitted)
    himbara_bank_podes |   .0877444   .0234123     3.75   0.000      .041317    .1341718
             atm_podes |   .0690584   .0212765     3.25   0.002     .0268663    .1112504
           agent_podes |   .1361127   .0263848     5.16   0.000     .0837907    .1884348
weak_cell_signal_podes |  -.0757371   .0136498    -5.55   0.000    -.1028052   -.0486691
  no_cell_signal_podes |   -.191393   .0333569    -5.74   0.000     -.257541   -.1252449
internet_cell_4G_podes |   .0353482   .0113163     3.12   0.002     .0129076    .0577887
   no_bankaccess_podes |  -.0417604   .0269019    -1.55   0.124     -.095108    .0115871
                 _cons |  -.1398595   .0581384    -2.41   0.018    -.2551501   -.0245689
----------------------------------------------------------------------------------------
Beginning 1000 regressions...
Completed regression 10
Completed regression 25
Completed regression 50
Completed regression 100
Completed regression 200
Completed regression 300
Completed regression 400
Completed regression 500
Completed regression 600
Completed regression 700
Completed regression 800
Completed regression 900
Completed regression 1000
RI p-val = 0
(results agentagents0IE are active now)

added matrix:
            e(pvalues) :  1 x 1

added scalar:
       e(control_mean) =  .48504542

added scalar:
         e(control_sd) =  .49979377

added scalar:
                e(obs) =  20743

added scalar:
         e(select_num) =  10

added macro:
            e(stratum) : "Yes"

added macro:
              e(lasso) : "Yes"
Original regression:

Linear regression                               Number of obs     =     20,743
                                                F(26, 104)        =      60.64
                                                Prob > F          =     0.0000
                                                R-squared         =     0.3468
                                                Root MSE          =     .39959

                                            (Std. err. adjusted for 105 clusters in idkab)
------------------------------------------------------------------------------------------
                         |               Robust
             agent_total | Coefficient  std. err.      t    P>|t|     [95% conf. interval]
-------------------------+----------------------------------------------------------------
                 treated |   .1841579   .0347403     5.30   0.000     .1152667    .2530492
                         |
            finalstratum |
                      2  |   .0654687    .045838     1.43   0.156    -.0254297    .1563671
                      3  |   .0037902    .045682     0.08   0.934    -.0867989    .0943793
                      4  |   .0877179   .0639663     1.37   0.173    -.0391296    .2145654
                      5  |   .1907952   .1028323     1.86   0.066    -.0131251    .3947155
                      6  |   .0679128   .0693334     0.98   0.330    -.0695779    .2054035
                      7  |   .0132037   .0450393     0.29   0.770    -.0761109    .1025183
                      8  |   .1433254   .0486854     2.94   0.004     .0467803    .2398704
                      9  |   .0218043   .0491245     0.44   0.658    -.0756113      .11922
                     10  |   .0756083   .0702172     1.08   0.284    -.0636351    .2148518
                     11  |    .125355   .0503667     2.49   0.014      .025476    .2252341
                     12  |   .1741825   .0600622     2.90   0.005     .0550769    .2932881
                     13  |   .0029361   .0407812     0.07   0.943    -.0779345    .0838068
                     14  |   .0993357   .0724815     1.37   0.173    -.0443978    .2430693
                   1000  |   .1091878   .0524227     2.08   0.040     .0052317    .2131439
                         |
       log_beneficiaries |    .077911   .0095843     8.13   0.000      .058905     .096917
             agent_mar18 |   .3846091   .0258801    14.86   0.000      .333288    .4359302
      himbara_bank_podes |   .0260208   .0133413     1.95   0.054    -.0004356    .0524772
               atm_podes |   .0271784   .0141465     1.92   0.057    -.0008746    .0552314
             agent_podes |   .0749722   .0199435     3.76   0.000     .0354235     .114521
  weak_cell_signal_podes |  -.0515722   .0115443    -4.47   0.000     -.074465   -.0286794
    no_cell_signal_podes |  -.2006716   .0327102    -6.13   0.000    -.2655372    -.135806
  internet_cell_4G_podes |   .0227981   .0084529     2.70   0.008     .0060357    .0395605
internet_cell_none_podes |  -.0795139   .0175454    -4.53   0.000    -.1143071   -.0447208
   desa_head_edu18_podes |   .0072654   .0024053     3.02   0.003     .0024957    .0120352
     no_bankaccess_podes |  -.0602254   .0221198    -2.72   0.008    -.1040899    -.016361
                   _cons |  -.0349664   .0499449    -0.70   0.485    -.1340091    .0640763
------------------------------------------------------------------------------------------
Beginning 1000 regressions...
Completed regression 10
Completed regression 25
Completed regression 50
Completed regression 100
Completed regression 200
Completed regression 300
Completed regression 400
Completed regression 500
Completed regression 600
Completed regression 700
Completed regression 800
Completed regression 900
Completed regression 1000
RI p-val = 0
(results agentallIE are active now)

added matrix:
            e(pvalues) :  1 x 1

. 
. 
. local prefix: display %tdCYND td(`c(current_date)')

. cap erase "$output/ster_files/20210226_finance/`prefix'_agents" // clear .ster if it already exists

. qui estimates dir

. foreach e in `r(names)' {
  2.     quietly estimates restore `e'
  3.     estimates title: `e'
  4.     quietly estimates save "$output/ster_files/20210226_finance/`prefix'_agents", append
  5. }

. 
. cap log close
